<template>
  <div
    class="head_button_item"
    @mouseover="handleMouseOver"
    @mouseleave="handleMouseLeave"
    :style="{ padding: shouldApplyPadding ? '0 0.5vw' : '0' }"
  >
    <img :src="internelImage" alt="Description of the image" />
    {{ internelText }}
  </div>
</template>

<script setup>
import { defineProps, onMounted, ref } from "vue";

const props = defineProps({
  buttonText: String,
  imageSrc: String,
  showPadding: Boolean,
});

const internelText = ref("");

const internelImage = ref("");

const shouldApplyPadding = ref(false); // 根据需要设置为 true 或 false

const handleMouseOver = () => {
  internelImage.value = require("../../assets/" +
    internelText.value +
    "_2.png");
};

const handleMouseLeave = () => {
  internelImage.value = require("../../assets/" +
    internelText.value +
    "_1.png");
};

onMounted(() => {
  internelText.value = props.buttonText;
  internelImage.value = props.imageSrc;
  if (props.showPadding) {
    shouldApplyPadding.value = true;
  }
});
</script>

<style scoped>
.head_button_item {
  margin-left: 1vh;
  margin-right: 1vh;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  cursor: pointer;
  font-size: 1vw;
  color: rgb(18, 119, 189);
}

.head_button_item:hover {
  color: #13227a; /* 悬浮时的字体颜色 */
}

.head_button_item img {
  height: 1vw;
}
</style>
